Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial commit to add launchpad and mission control into QMK. #4762

Closed
wants to merge 5 commits into from

Conversation

lbibass
Copy link
Contributor

@lbibass lbibass commented Jan 2, 2019

I am TRYING to add in Mission Control and Launchpad into QMK.

Description

I am following what @grota did in his addition of brightness controls in #4477.

As of right now, it is not working, and I cannot figure out why.

Types of changes

  • Core
  • Bugfix
  • New Feature
  • Enhancement/Optimization
  • Keyboard (addition or update)
  • Keymap/Layout/Userspace (addition or update)
  • Documentation

Issues Fixed or Closed by this PR

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document. (https://docs.qmk.fm/#/contributing)
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@lbibass
Copy link
Contributor Author

lbibass commented Jan 2, 2019

Looking at https://www.usb.org/sites/default/files/hutrr77_-_desktop_controls_0.pdf, the keycodes I am using should work. Also, I think that I have done everything that grota did. Not sure as to why it fails to compile.

@grota
Copy link
Contributor

grota commented Jan 2, 2019

I think it's because in the enum KC_MISSION_CONTROL ends up having the value 0xC0 (it's the 16th from KC_MEDIA_EJECT). Not sure how the policy should be here.

@lbibass
Copy link
Contributor Author

lbibass commented Jan 2, 2019

yeah, I am just confused at this point. it SHOULD work. But it doesn't. I mean, it works in the official docs!

@grota
Copy link
Contributor

grota commented Jan 2, 2019

No, I mean that just looking at the output of the travis build I think that KC_LAUNCHPAD ends up having the value 0xC0 in the enum like its follower KC_FN0 which might messes things up.
I think the main problem is that there's the assumption that the number of keycodes can only be 255 (0xff) in total. And that's why the values are so contiguous. Someone more informed and expert than me should look at it.

@fauxpark
Copy link
Member

fauxpark commented Jan 3, 2019

There is now only one free spot left after the screen brightness keycodes (0xBF). The rest of the space has been already filled.

If you're looking for a way to make your keyboard more Apple-y, have a look at #2179 where I proposed adding the actual Apple Fn key. Unfortunately there is something of a drawback to it (you have to use an Apple VID/PID, and modify the QMK internals a little) so for legal reasons it wasn't implemented officially, however there is a diff if you want to follow along.

@fauxpark
Copy link
Member

fauxpark commented Jan 3, 2019

@drashna it seems as though we could free up more space by replacing instances of KC_FN* with F(*) as they appear to end up doing the exact same thing in action_for_key() (and F() allows for a full 12 bits worth of macros vs 5 bits with the FN* keycodes):

        case KC_FN0 ... KC_FN31:
            action.code = keymap_function_id_to_action(FN_INDEX(keycode));
            break;
      // ... 
       case QK_FUNCTION ... QK_FUNCTION_MAX: ;
            // Is a shortcut for function action_layer, pull last 12bits
            // This means we have 4,096 FN macros at our disposal
            action.code = keymap_function_id_to_action( (int)keycode & 0xFFF );
            break;

@@ -194,6 +197,8 @@ typedef struct {
(key == KC_WWW_REFRESH ? AC_REFRESH : \
(key == KC_BRIGHTNESS_UP ? BRIGHTNESSUP : \
(key == KC_BRIGHTNESS_DOWN ? BRIGHTNESSDOWN : \
(key == KC_LAUNCHPAD ? LAUNCHPAD : \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the order matters, then launchpad should be last.

tmk_core/common/report.h Outdated Show resolved Hide resolved
@lbibass
Copy link
Contributor Author

lbibass commented Jan 3, 2019

okay, that makes a little more sense. I assume that there is no way to get rid of fn0? Is it necessary in QMK?

also thanks @drashna, it compiles now! however, mission control does nothing. Launchpad, unfortunately, outputs g now. I don't think that it is possible to add in launchpad and mission control without getting rid of fn0, which I don't think is possible.

@fauxpark
Copy link
Member

fauxpark commented Jan 3, 2019

Removing the FN keycodes right now will break many keymaps which still use them. They must all be replaced with F() as I mentioned above.

Also, the various HID descriptors currently only declare consumer usages up to 0x029C, which probably explains why you are still not getting the correct behaviour.

@grota
Copy link
Contributor

grota commented Jan 3, 2019

Are we really limited to 255 keycodes? Can't we "expand" the cardinality or maybe use another "space"?

@fauxpark
Copy link
Member

fauxpark commented Jan 3, 2019

Keycodes in QMK are actually 16 bits wide, but even then there are few gaps because a lot of QMK features take keycodes from the basic set as a parameter in the low byte.

Have a look at quantum_keycodes.h ;)

@lbibass
Copy link
Contributor Author

lbibass commented Jan 4, 2019

So are you saying to add those keycodes to quantum_keycodes.h @fauxpark? That does seem pretty interesting, but I am not sure as to how I would do that.

@fauxpark
Copy link
Member

fauxpark commented Jan 5, 2019

I guess it is technically possible, but since your new keycodes are still part of the consumer page it's probably a bad idea to fragment it like that. My point was to show how crowded the keycode space already is, even with 16 bits. Huge chunks of it are taken up by things like Mod-Tap & Layer-Tap which interpret the lower 8 bits as a basic keycode, and some part of the high byte as a modifier or layer etc.

The best way forward IMO is to remove the FN keycodes, but that will take a bit of work due to all the keymaps referencing them.

@grota
Copy link
Contributor

grota commented Jan 5, 2019

wouldn't it be better to move all our Consumer Page keycodes into quantum_keycodes.h?

My rationale is as follows:

  • I don't think they need to be Shift-ed, Alt-ed and so on.
  • There are potentially a lot of them in the spec, we might want to add more than 30 and we will run out of space again.
  • The basic set is already crowded and we would give it some space to breathe.

@fauxpark
Copy link
Member

fauxpark commented Jan 5, 2019

If you can find space for them, sure. For reference, here's what the space looks like right now (as far as I understand it):

0000 - 00FF: Basic keycodes

      │ 0       │ 1       │ 2       │ 3       │ 4       │ 5       │ 6       │ 7       │ 8       │ 9       │ A       │ B       │ C       │ D       │ E       │ F
──────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼────────
 0000 │ KC_NO   │ KC_TRNS │ KC_POST │ KC_UNDF │ KC_A    │ KC_B    │ KC_C    │ KC_D    │ KC_E    │ KC_F    │ KC_G    │ KC_H    │ KC_I    │ KC_J    │ KC_K    │ KC_L
 0010 │ KC_M    │ KC_N    │ KC_O    │ KC_P    │ KC_Q    │ KC_R    │ KC_S    │ KC_T    │ KC_U    │ KC_V    │ KC_W    │ KC_X    │ KC_Y    │ KC_Z    │ KC_1    │ KC_2
 0020 │ KC_3    │ KC_4    │ KC_5    │ KC_6    │ KC_7    │ KC_8    │ KC_9    │ KC_0    │ KC_ENT  │ KC_ESC  │ KC_BSPC │ KC_TAB  │ KC_SPC  │ KC_MINS │ KC_EQL  │ KC_LBRC
 0030 │ KC_RBRC │ KC_BSLS │ KC_NUHS │ KC_SCLN │ KC_QUOT │ KC_GRV  │ KC_COMM │ KC_DOT  │ KC_SLSH │ KC_CLCK │ KC_F1   │ KC_F2   │ KC_F3   │ KC_F4   │ KC_F5   │ KC_F6
 0040 │ KC_F7   │ KC_F8   │ KC_F9   │ KC_F10  │ KC_F11  │ KC_F12  │ KC_PSCR │ KC_SLCK │ KC_PAUS │ KC_INS  │ KC_HOME │ KC_PGUP │ KC_DEL  │ KC_END  │ KC_PGDN │ KC_RGHT
 0050 │ KC_LEFT │ KC_DOWN │ KC_UP   │ KC_NLCK │ KC_PSLS │ KC_PAST │ KC_PMNS │ KC_PPLS │ KC_PENT │ KC_KP_1 │ KC_KP_2 │ KC_KP_3 │ KC_KP_4 │ KC_KP_5 │ KC_KP_6 │ KC_KP_7
 0060 │ KC_KP_8 │ KC_KP_9 │ KC_KP_0 │ KC_PDOT │ KC_NUBS │ KC_APP  │ KC_KPWR │ KC_PEQL │ KC_F13  │ KC_F14  │ KC_F15  │ KC_F16  │ KC_F17  │ KC_F18  │ KC_F19  │ KC_F20
 0070 │ KC_F21  │ KC_F22  │ KC_F23  │ KC_F24  │ KC_EXEC │ KC_HELP │ KC_MENU │ KC_SLCT │ KC_STOP │ KC_AGIN │ KC_UNDO │ KC_CUT  │ KC_COPY │ KC_PSTE │ KC_FIND │ KC_KMUT
 0080 │ KC_KVLU │ KC_KVLD │ KC_LCAP │ KC_LNUM │ KC_LSCR │ KC_PCMM │ KC_EQAS │ KC_INT1 │ KC_INT2 │ KC_INT3 │ KC_INT4 │ KC_INT5 │ KC_INT6 │ KC_INT7 │ KC_INT8 │ KC_INT9
 0090 │ KC_LNG1 │ KC_LNG2 │ KC_LNG3 │ KC_LNG4 │ KC_LNG5 │ KC_LNG6 │ KC_LNG7 │ KC_LNG8 │ KC_LNG9 │ KC_ERAS │ KC_SYRQ │ KC_CNCL │ KC_CLR  │ KC_PRIR │ KC_RETN │ KC_SEP
 00A0 │ KC_OUT  │ KC_OPER │ KC_CLAG │ KC_CRSL │ KC_EXSL │ KC_PWR  │ KC_SLEP │ KC_WAKE │ KC_MUTE │ KC_VOLU │ KC_VOLD │ KC_MNXT │ KC_MPRV │ KC_MSTP │ KC_MPLY │ KC_MSEL
 00B0 │ KC_EJCT │ KC_MAIL │ KC_CALC │ KC_MYCM │ KC_WSCH │ KC_WHOM │ KC_WBAK │ KC_WFWD │ KC_WSTP │ KC_WREF │ KC_WFAV │ KC_MFFD │ KC_MRWD │ KC_BRIU │ KC_BRID │
 00C0 │ KC_FN0  │ KC_FN1  │ KC_FN2  │ KC_FN3  │ KC_FN4  │ KC_FN5  │ KC_FN6  │ KC_FN7  │ KC_FN8  │ KC_FN9  │ KC_FN10 │ KC_FN11 │ KC_FN12 │ KC_FN13 │ KC_FN14 │ KC_FN15
 00D0 │ KC_FN16 │ KC_FN17 │ KC_FN18 │ KC_FN19 │ KC_FN20 │ KC_FN21 │ KC_FN22 │ KC_FN23 │ KC_FN24 │ KC_FN25 │ KC_FN26 │ KC_FN27 │ KC_FN28 │ KC_FN29 │ KC_FN30 │ KC_FN31
 00E0 │ KC_LCTL │ KC_LSFT │ KC_LALT │ KC_LGUI │ KC_RCTL │ KC_RSFT │ KC_RALT │ KC_RGUI │         │         │         │         │         │         │         │
 00F0 │ KC_MS_U │ KC_MS_D │ KC_MS_L │ KC_MS_R │ KC_BTN1 │ KC_BTN2 │ KC_BTN3 │ KC_BTN4 │ KC_BTN5 │ KC_WH_U │ KC_WH_D │ KC_WH_L │ KC_WH_R │ KC_ACL0 │ KC_ACL1 │ KC_ACL2

0100 - 01FF: LCTL(kc)
0200 - 02FF: LSFT(kc)
0300 - 03FF: LCTL(LSFT(kc))
0400 - 04FF: LALT(kc)
0500 - 05FF: LCTL(LALT(kc))
0600 - 06FF: LSFT(LALT(kc))
0700 - 07FF: LCTL(LSFT(LALT(kc)))
0800 - 08FF: LGUI(kc)
0900 - 09FF: LCTL(LGUI(kc))
0A00 - 0AFF: LSFT(LGUI(kc))
0B00 - 0BFF: LCTL(LSFT(LGUI(kc)))
0C00 - 0CFF: LALT(LGUI(kc))
0D00 - 0DFF: LCTL(LALT(LGUI(kc)))
0E00 - 0EFF: LSFT(LALT(LGUI(kc)))
0F00 - 0FFF: LCTL(LSFT(LALT(LGUI(kc))))

1000 - 10FF: Basic keycodes with right flag set but no modifiers

1100 - 11FF: RCTL(kc)
1200 - 12FF: RSFT(kc)
1300 - 13FF: RCTL(RSFT(kc))
1400 - 14FF: RALT(kc)
1500 - 15FF: RCTL(RALT(kc))
1600 - 16FF: RSFT(RALT(kc))
1700 - 17FF: RCTL(RSFT(RALT(kc)))
1800 - 18FF: RGUI(kc)
1900 - 19FF: RCTL(RGUI(kc))
1A00 - 1AFF: RSFT(RGUI(kc))
1B00 - 1BFF: RCTL(RSFT(RGUI(kc)))
1C00 - 1CFF: RALT(RGUI(kc))
1D00 - 1DFF: RCTL(RALT(RGUI(kc)))
1E00 - 1EFF: RSFT(RALT(RGUI(kc)))
1F00 - 1FFF: RCTL(RSFT(RALT(RGUI(kc))))

2000 - 2FFF: F(0) to F(4095)
3000 - 3FFF: M(0) to M(4095)

4000 - 4FFF: LT(0, kc) to LT(15, kc)
5000 - 50FF: TO(0) to TO(255)
5100 - 51FF: MO(0) to MO(255)
5200 - 52FF: DF(0) to DF(255)
5300 - 53FF: TG(0) to TG(255)
5400 - 54FF: OSL(0) to OSL(255)
5500 - 55FF: OSM(mod)

5600 - 56FF: Unused

5700 - 57FF: TD(0) to TD(255)
5800 - 58FF: TT(0) to TT(255)
5900 - 59FF: LM(0, mod) to LM(15, mod)

5A00 - 5A30: Steno keys (unused if feature disabled)

5A31 - 5AFF: Unused

5B00 - 5BFF: Swap hands (unused if feature disabled)

5C00 - 5FFF: Loose QMK keycodes (RESET, DEBUG, Bootmagic, ...)

6000 - 7FFF: MT(mod, kc)

8000 - FFFF: Unicode (unused if feature disabled)
8000 - 83FF: Unicodemap (unused if feature disabled)

The big one is the Unicode feature that hogs all of the remaining keycodes when it's enabled.

@grota
Copy link
Contributor

grota commented Jan 5, 2019

yep. Not right now because I have to study some things for work, but I'll look into it "soonish" 😄

@grota
Copy link
Contributor

grota commented Jan 9, 2019

@fauxpark just out of curiosity, I did not understand this segment here: 1000 - 10FF: Basic keycodes with right flag set but no modifiers what does it represent again?

@fauxpark
Copy link
Member

fauxpark commented Jan 9, 2019

It's just a side effect of how the modifiers are represented in keycodes, which unfortunately takes up those 256 keycode slots. They act exactly like unmodified keycodes because they have the "right modifier" flag set (0x1000) but no modifiers (the set bits in 0x0F00). For all intents and purposes they are useless.

@drashna
Copy link
Member

drashna commented Sep 21, 2019

There are a number of merge conflicts here.

Alternatively, is it okay if we close the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants